package com.sunrise.generico.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Transient;

import lombok.Getter;
import lombok.Setter;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.GrantedAuthorityImpl;
import org.springframework.security.core.userdetails.UserDetails;

public class UsuarioLogado implements UserDetails {
	
private static final long serialVersionUID = 1485134708022738954L;
	
	@Getter
	private List<GrantedAuthority> authorities;
	
	@Getter @Setter
	private String username;
	
	@Getter @Setter
	private String password;
	
	@Getter @Setter
	private boolean accountNonExpired;
	
	@Getter @Setter
	private boolean accountNonLocked;
	
	@Getter @Setter
	private boolean credentialsNonExpired;
	
	@Getter @Setter
	private boolean enabled;
	
	@Getter @Setter
	private String nome;
	
	@Getter @Setter
	private String email;
	
	@Transient
	@Getter @Setter
	private String primeiroNome;
	
	public void setAuthorities(Collection<GrantedAuthorityImpl> authorities) {
		this.authorities = new ArrayList<GrantedAuthority>();
		for (GrantedAuthorityImpl auth : authorities) {
			this.authorities.add(auth);
		}
	}
	
}
